.PHONY: clean merge copy_loader

boot.bin: boot.asm
	nasm boot.asm -o boot.bin

boot.img:
	bximage -q -func=create -fd=1.44M boot.img

merge: boot.bin boot.img
	dd if=boot.bin of=boot.img bs=512 count=1 conv=notrunc

loader.bin: loader.asm
	nasm loader.asm -o loader.bin

copy_loader: boot.img loader.bin
	sudo mount boot.img /media/ -t vfat -o loop
	sudo cp loader.bin /media/
	sudo sync
	sudo umount /media/

clean :
	rm -f boot.img boot.bin loader.bin

run: merge copy_loader
	qemu-system-i386 -drive file=boot.img,index=0,if=floppy,format=raw -boot order=a

debug: merge copy_loader
	qemu-system-i386 -drive file=boot.img,index=0,if=floppy,format=raw -boot order=a -s -S
